package com.ruoyi.web.controller.borehole;

import com.ruoyi.common.annotation.RepeatSubmit;
import com.ruoyi.common.core.domain.PageQuery;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.core.validate.QueryGroup;
import com.ruoyi.web.domain.query.BhPlansPageQuery;
import com.ruoyi.web.domain.query.CreatePlanQuery;
import com.ruoyi.web.domain.vo.BhPlansPageVO;
import com.ruoyi.web.service.BhPlansService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

@Slf4j
@Tag(name = "检查计划")
@RestController
@RequestMapping("/checkPlan")
public class CheckPlanController {

    @Autowired
    private BhPlansService bhPlansService;

    @Operation(summary = "检查计划列表页 - 分页查询")
    @GetMapping("/getPlanPage")
    public TableDataInfo<BhPlansPageVO> getPlanPage(@Validated(QueryGroup.class) BhPlansPageQuery bhPlansPageQuery, PageQuery pageQuery) {
        return bhPlansService.getPlanPage(bhPlansPageQuery, pageQuery, false);
    }

    @Operation(summary = "制定计划-下发")
    @RepeatSubmit
    @PostMapping("/createPlan")
    public R<Void> createPlan(@RequestBody CreatePlanQuery createPlanQuery) {
        return bhPlansService.createPlan(createPlanQuery);
    }

    @Operation(summary = "检查计划详情")
    @GetMapping("/getPlanDetail")
    public R<BhPlansPageVO> getPlanDetail(@RequestParam("id") Integer id) {
        return bhPlansService.getPlanDetail(id);
    }

    @Operation(summary = "编辑检查计划")
    @PostMapping("/modPlan")
    public R<Void> modPlan(@RequestBody CreatePlanQuery modPlanQuery) {
        return bhPlansService.modPlan(modPlanQuery);
    }

    @Operation(summary = "删除检查计划")
    @RepeatSubmit
    @GetMapping("/delPlan")
    public R<Void> delPlan(@RequestParam("id") Integer id) {
        return bhPlansService.delPlan(id);
    }
}
